package net.starwifi.duobao.dto;

import com.fasterxml.jackson.annotation.JsonProperty;
import net.starwifi.duobao.entity.DBOrder;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by ruoo on 15/12/27.
 */
public class DBOrderDTO implements Serializable {


    private Long id;

    private String ipInfo;

    private String dateInfo;

    private String mobileInfo;

    private int quantity;


    public DBOrderDTO(Long id, String ipInfo, String dateInfo, String mobileInfo,int quantity) {
        this.id = id;
        this.ipInfo = ipInfo;
        this.dateInfo = dateInfo;
        this.mobileInfo = mobileInfo;
        this.quantity=quantity;
    }

    public static List<DBOrderDTO> getList(List<DBOrder> dbOrders){
        if(dbOrders==null){
            return new ArrayList<DBOrderDTO>();
        }
        List<DBOrderDTO> dbOrderDTOs=new ArrayList<DBOrderDTO>();
        for(DBOrder dbOrder:dbOrders){
            dbOrderDTOs.add(new DBOrderDTO(dbOrder.getId(),dbOrder.getIpInfo(),dbOrder.getDateInfo(),dbOrder.getMobileInfo(),dbOrder.getQuantity()));
        }
        return dbOrderDTOs;
    }


    @JsonProperty
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @JsonProperty
    public String getIpInfo() {
        return ipInfo;
    }

    public void setIpInfo(String ipInfo) {
        this.ipInfo = ipInfo;
    }

    @JsonProperty
    public String getDateInfo() {
        return dateInfo;
    }

    public void setDateInfo(String dateInfo) {
        this.dateInfo = dateInfo;
    }

    @JsonProperty
    public String getMobileInfo() {
        return mobileInfo;
    }

    public void setMobileInfo(String mobileInfo) {
        this.mobileInfo = mobileInfo;
    }

    @JsonProperty
    public int getQuantity() {
        return quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }
}
